import chardet
import argparse


def get_encoding(file: str):
    print(file)
    with open(file, "rb") as f:
        data = f.read()
        encoding_type = chardet.detect(data)
        print(encoding_type)
        return encoding_type['encoding']


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("file")
    args = parser.parse_args()
    get_encoding(**vars(args))
